#ifndef __USART_BOARD_H__
#define __USART_BOARD_H__

#include "system.h"
#include "tremo_uart.h"
#include "tremo_lpuart.h"
#include "fifo.h"


#define SYS_UART_CNT                            (2)
#define UART_INDEX_DEBUG                        (3)     //使用的串口UART0
#define UART_INDEX_RS232                        (0)     //使用的串口 LPUART
#define UART_INDEX_485                          (1)     //使用的是UART1

#define LPUART_FIFO_BUFFER_SIZE (256)
#define UART1_FIFO_BUFFER_SIZE                  (256)
#define AT_COMMAND_BUFFER_LEN				    (64)


#define AT_COMMAND_RX_DONE_MASK                 (0x8000)
#define AT_COMMAND_INTERFACE_START
#define AT_COMMAND_INTERFACE_STOP
#define AT_COMMAND_SEND_DATA(puffer,len)        UartSendData(UART_INDEX_DEBUG,puffer,len)

extern uint16_t AtCommandState;
extern uint8_t AtCommandBuf[AT_COMMAND_BUFFER_LEN];


#pragma pack(1)
typedef struct{
    uint8_t  index;                     //串口系统索引
    FIFO_S_t rxBuffCtrl;                //接收缓存控制信息
}UART_INFO_STR;

#pragma pack()


void UartInit(void);
void LpuartIrqProcess(void);
void UartSendData(uint8_t portIndex, const uint8_t *p, uint32_t len);
int UsartGetOneData(int portIndex, uint8_t *pData);
void UsartFifoFlush(int portIndex);

void ReEnableUart(uart_t* uart);
#endif
